//
//  ReLogin.m
//  SP2P
//
//  Created by EIMS-IOS on 15/6/23.
//  Copyright (c) 2015年 EIMS. All rights reserved.
//

#import "ReLogin.h"
#import "RestUIAlertView.h"
#import "SGLoginViewController.h"
#import "SetPayPasswordViewController.h"
#import "AddBankCardViewController.h"

@implementation ReLogin

+ (void)outTheTimeRelogin:(UIViewController *)viewController {
    // 登录过期
    RestUIAlertView *restAlert  =  [[RestUIAlertView alloc] initWithTitle:@"登录提示" content:@"亲，未登录或登录过期，请重新登录！"];
    restAlert.rightBlock = ^() {
        SGLoginViewController *loginVC = [[SGLoginViewController alloc] init];
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:loginVC];
        [viewController presentViewController:navigationController animated:YES completion:nil];
    };
    
    restAlert.leftBlock = ^() {   // 取消按钮
        DLOG(@"取消");
    };
    restAlert.dismissBlock = ^() {
    };
    [restAlert show];

}

+ (void)goLogin:(UIViewController *)viewController {
    // 登录过期
    RestUIAlertView *restAlert  = [[RestUIAlertView alloc] initWithTitle:@"登录提示" content:@"请先登录！"];
    restAlert.rightBlock = ^() {
        SGLoginViewController *loginVC = [[SGLoginViewController alloc] init];
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:loginVC];
        [viewController presentViewController:navigationController animated:YES completion:nil];
    };
    
    restAlert.leftBlock = ^() {    // 取消按钮
        DLOG(@"取消");
    };
    restAlert.dismissBlock = ^() {
    };
    [restAlert show];
    
}

/**
 *  检测是否设置交易密码
 */
+ (void)testTradePasswordStaus:(UIViewController *)viewController {
    if (AppDelegateInstance.userInfo == nil) {
        [self goLogin:viewController];
    }
    if (!AppDelegateInstance.userInfo.isPayPasswordStatus) {
        return;
    }
    // 没有设置交易密码
    RestUIAlertView *restAlert  = [[RestUIAlertView alloc] initWithTitle:@"您尚未设置交易密码" content:@"是否前去设置交易密码？"];
    restAlert.rightBlock = ^() {
        //设置交易密码
        SetPayPasswordViewController *setPayPassword = [[SetPayPasswordViewController alloc] init];
        if (viewController.navigationController.viewControllers.count == 1) {
            setPayPassword.hidesBottomBarWhenPushed = YES;
        }
        setPayPassword.editType = 1;
        [viewController.navigationController pushViewController:setPayPassword animated:YES];
    };
    
    restAlert.leftBlock = ^() {    // 取消按钮
        DLOG(@"取消");
    };
    [restAlert show];
}

/**
 *  检测是否实名认证
 */
+ (void)testRealNameVerifyStaus:(UIViewController *)viewController {
    if (AppDelegateInstance.userInfo == nil) {
        [self goLogin:viewController];
    }
    if (AppDelegateInstance.userInfo.realName.length <= 0) {
        // 没有实名认证
        RestUIAlertView *restAlert  = [[RestUIAlertView alloc] initWithTitle:@"您尚未进行实名认证" content:@"是否前去实名认证？"];
        restAlert.rightBlock = ^() {
            //去实名认证
            AddBankCardViewController *addBankCard = [[AddBankCardViewController alloc] init];
            addBankCard.editType = 1;
            if (viewController.navigationController.viewControllers.count == 1) {
                addBankCard.hidesBottomBarWhenPushed = YES;
            }
            [viewController.navigationController pushViewController:addBankCard animated:YES];
        };
        
        restAlert.leftBlock = ^() {    // 取消按钮
            DLOG(@"取消");
        };
        [restAlert show];
    }
    
    
}

@end
